/**
 * @param {number[][]} matrix
 * @param {number} target
 * @return {boolean}
 */
// 二分查找
var searchMatrix = function(matrix, target) {
    let m = matrix.length, n = matrix[0].length
    let left = 0, right = m * n - 1
    while(left <= right) {
        let middle = (left + right) >> 1
        let i = Math.floor(middle / n)
        let j = middle % n
        if(target === matrix[i][j]) return true
        else if(target > matrix[i][j]) {
            left = middle + 1
        } else {
            right = middle - 1
        }
    }
    return false
};